<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class CI_Escort_entity{
	var $current_dbprefix = "";
	var $CI;
	var $id = 0;
	var $user_id = 0;
	var $times_visited = 0;
	var $number_first_standing = 0;
	var $times_phone_displayed = 0;
	var $wallet = 0;
	var $sex = "";
	var $public_sex = 0;
	var $sexual_orientation_id = 0;
	var $public_sexual_orientation = 0;
	var $birth_date = 0;
	var $public_birth_date = 0;
	var $country_id = 0;
	var $public_country = 0;
	var $hair_color_id = 0;
	var $hair_size_id = 0;
	var $hair_style_id = 0;
	var $public_hair = 0;
	var $eye_id = 0;
	var $public_eye = 0;
	var $height = 0;
	var $public_height = 0;
	var $weight = 0;
	var $public_weight = 0;
	var $measure_1 = 0;
	var $measure_2 = 0;
	var $measure_3 = 0;
	var $public_measures = 0;
	var $public_schedule = 0;
	var $working_place_ids = "";
	var $public_working_places = 0;
	var $travel_ids = "";
	var $public_travel = 0;
	var $serve_to_ids = "";
	var $public_serve_to = 0;
	var $service_ids = "";
	var $public_services = 0;
	var $payment_method_ids = "";
	var $public_payment_method = 0;
	var $transport_include_id = 0;
	var $public_transport_include = 0;
	var $public_phone = 0;
	var $public_email = 0;
	var $public_address = 0;
	var $geolocation = "";
	var $public_geolocation = 0;
	var $public_map = 0;
	var $show_address_on_map = 0;
	var $receive_message = 0;
	var $promotion_code = "";
	var $commercial_lead = 0;
	var $package_ids = "";
	var $serves_to_ids = "";
	var $public_serves_to = 0;
	var $public_working_calendar = 0;
	var $public_pricing_time = 0;
	var $extras_ids = 0;
	var $public_extras = 0;
	var $expire_contract_time =0;
	var $subscription_id = 0;
	var $escort_category_id = 0;
	var $language_ids = "";
	var $public_language_ids = "";
	var $point = 0;
	var $published = 0;
	var $breasts_size_id = 0;
	var $public_breasts_size = 0;
	var $penis_size_id = 0;
	var $public_penis_size = 0;
	var $escort_name = "";
	var $escort_email = "";
	var $escort_address = "";
	var $escort_phone = "";
	var $state_id = 0; 	
	var $province_id = 0; 	
	var $city_id = 0;
	var $places_list_ids_contract = "";
	var $priority_id = 0;
	var $add_point_edit_profile = 0;
	var $profession_id = 0;
	var $public_profession = 0;
	var $image_face_censor = 0;
	var $apply_services = 0;
	var $borncountry_id = 0;
	var $public_borncountry = 0;
	var $order_controll = 0;
	var $order_value = 0;
	
	function __construct() {
		$this->CI = &get_instance();
		$this->current_dbprefix = $this->CI->db->dbprefix;
		$this->CI->db->set_dbprefix('default_');
	}
	function __destruct() {
		$this->CI->db->set_dbprefix($this->current_dbprefix);
	}
	
	function init($cmd, $input)
	{
		$this->CI->db->set_dbprefix('default_');
		if($cmd == 'user_id')
		{
			$result = $this->CI->db->where('user_id',$input)->get(TBL_ESCORT)->result();
		}
		else if($cmd == 'id')
		{
			$result = $this->CI->db->where('id',$input)->get(TBL_ESCORT)->result();
		}
		else
		{
			return false;
		}
		
		if( !empty($result) )
		{
			$this->id = $result[0]->id;
			$this->user_id = $result[0]->user_id;
			$this->times_visited = $result[0]->times_visited;
			$this->number_first_standing = $result[0]->number_first_standing;
			$this->times_phone_displayed = $result[0]->times_phone_displayed;
			$this->wallet = $result[0]->wallet;
			$this->sex = $result[0]->sex;
			$this->public_sex = $result[0]->public_sex;
			$this->sexual_orientation_id = $result[0]->sexual_orientation_id;
			$this->public_sexual_orientation = $result[0]->public_sexual_orientation;
			$this->birth_date = $result[0]->birth_date;
			$this->public_birth_date = $result[0]->public_birth_date;
			$this->country_id = $result[0]->country_id;
			$this->public_country = $result[0]->public_country;
			$this->hair_color_id = $result[0]->hair_color_id;
			$this->hair_size_id = $result[0]->hair_size_id;
			$this->hair_style_id = $result[0]->hair_style_id;
			$this->public_hair = $result[0]->public_hair;
		 	$this->eye_id = $result[0]->eye_id;
			$this->public_eye = $result[0]->public_eye;
			$this->height = $result[0]->height;
			$this->public_height = $result[0]->public_height;
			$this->weight = $result[0]->weight;
			$this->public_weight = $result[0]->public_weight;
			$this->measure_1 = $result[0]->measure_1;
			$this->measure_2 = $result[0]->measure_2;
			$this->measure_3 = $result[0]->measure_3;
			$this->public_measures = $result[0]->public_measures;
			$this->public_schedule = $result[0]->public_schedule;
			$this->working_place_ids = $result[0]->working_place_ids;
			$this->public_working_places = $result[0]->public_working_places;
			$this->travel_ids = $result[0]->travel_ids;
			$this->public_travel = $result[0]->public_travel;
			$this->serve_to_ids = $result[0]->serve_to_ids;
			$this->public_serve_to = $result[0]->public_serve_to;
			$this->service_ids = $result[0]->service_ids;
			$this->public_services = $result[0]->public_services;
			$this->payment_method_ids = $result[0]->payment_method_ids;
			$this->public_payment_method = $result[0]->public_payment_method;
			$this->transport_include_id = $result[0]->transport_include_id;
			$this->public_transport_include = $result[0]->public_transport_include;
			$this->public_phone = $result[0]->public_phone;
			$this->public_email = $result[0]->public_email;
			$this->public_address = $result[0]->public_address;
			$this->geolocation = $result[0]->geolocation;
			$this->public_geolocation = $result[0]->public_geolocation;
			$this->public_map = $result[0]->public_map;
			$this->show_address_on_map = $result[0]->show_address_on_map;
			$this->receive_message = $result[0]->receive_message;
			$this->promotion_code = $result[0]->promotion_code;
			$this->commercial_lead = $result[0]->commercial_lead;
			$this->package_ids = $result[0]->package_ids;
			$this->serves_to_ids = $result[0]->serves_to_ids;
			$this->public_serves_to = $result[0]->public_serves_to;
			$this->public_working_calendar = $result[0]->public_working_calendar;
			$this->public_pricing_time = $result[0]->public_pricing_time;
			$this->extras_ids = $result[0]->extras_ids;
			$this->public_extras = $result[0]->public_extras;
			$this->expire_contract_time = $result[0]->expire_contract_time;
			$this->subscription_id = $result[0]->subscription_id;
			$this->escort_category_id = $result[0]->escort_category_id;
			$this->language_ids = $result[0]->language_ids;
			$this->public_language_ids = $result[0]->public_language_ids;
			$this->point = $result[0]->point;
			$this->published = $result[0]->published;
			$this->payment_pending = $result[0]->payment_pending;
			$this->breasts_size_id = $result[0]->breasts_size_id;
			$this->public_breasts_size = $result[0]->public_breasts_size;
			$this->penis_size_id = $result[0]->penis_size_id;
			$this->public_penis_size = $result[0]->public_penis_size;
			$this->escort_name = $result[0]->escort_name;
			$this->escort_email = $result[0]->escort_email;
			$this->escort_address = $result[0]->escort_address;
			$this->escort_phone = $result[0]->escort_phone;
			$this->state_id = $result[0]->state_id;
			$this->province_id = $result[0]->province_id;
			$this->city_id = $result[0]->city_id;
			$this->places_list_ids_contract = $result[0]->places_list_ids_contract;
			$this->priority_id = $result[0]->priority_id;
			$this->add_point_edit_profile = $result[0]->add_point_edit_profile;
			$this->profession_id = $result[0]->profession_id;
			$this->public_profession = $result[0]->public_profession;
			$this->image_face_censor = $result[0]->image_face_censor;
			$this->apply_services = $result[0]->apply_services;
			$this->borncountry_id = $result[0]->borncountry_id;
			$this->public_borncountry = $result[0]->public_borncountry;
			$this->order_controll = $result[0]->order_controll;
			$this->order_value = $result[0]->order_value;
			
			$LOCKED = $this->CI->locked_escort_entity->init('escort_id', $this->id);
			if( !$LOCKED){
				$this->CI->locked_escort_entity->createNewLockedEscortEntity($this->id);
			}
			return $this;
		}
		return false;
	}
	
	function setId($input){ $this->id=$input;}
	function setUserId($input){ $this->user_id=$input;}
	function setTimesVisited($input){ $this->times_visited=$input;}
	function setNumberFirstStanding($input){ $this->number_first_standing=$input; }
	function setTimesPhoneDisplayed($input){ $this->times_phone_displayed=$input;}
	function setWallet($input){ $this->wallet=$input;}
	function setSex($input){ $this->sex=$input;}
	function setPublicSex($input){ $this->public_sex=$input;}
	function setSexualOrientationId($input){ $this->sexual_orientation_id=$input;}
	function setPublicSexualOrientation($input){ $this->public_sexual_orientation=$input;}
	function setBirthDate($input){ $this->birth_date=$input;}
	function setPublicBirthDate($input){ $this->public_birth_date=$input;}
	function setCountryId($input){ $this->country_id=$input;}
	function setPublicCountry($input){ $this->public_country=$input;}
	function setHairColorId($input){ $this->hair_color_id=$input;}
	function setHairSizeId($input){ $this->hair_size_id=$input;}
	function setHairStyleId($input){ $this->hair_style_id=$input;}
	function setPublicHair($input){ $this->public_hair=$input;}
	function setEyeId($input){ $this->eye_id=$input;}
	function setPublicEye($input){ $this->public_eye=$input;}
	function setHeight($input){ $this->height=$input;}
	function setPublicHeight($input){ $this->public_height=$input;}
	function setWeight($input){ $this->weight=$input;}
	function setPublicWeight($input){ $this->public_weight=$input;}
	function setMeasure1($input){ $this->measure_1=$input;}
	function setMeasure2($input){ $this->measure_2=$input;}
	function setMeasure3($input){ $this->measure_3=$input;}
	function setPublicMeasures($input){ $this->public_measures=$input;}
	function setPublicSchedule($input){ $this->public_schedule=$input;}
	function setWorkingPlaceIds($input){ $this->working_place_ids=$input;}
	function setPublicWorkingPlaces($input){ $this->public_working_places=$input;}
	function setTravelIds($input){ $this->travel_ids=$input;}
	function setPublicTravel($input){ $this->public_travel=$input;}
	function setServeToIds($input){ $this->serve_to_ids=$input;}
	function setPublicServeTo($input){ $this->public_serve_to=$input;}
	function setServiceIds($input){ $this->service_ids=$input;}
	function setPublicServices($input){ $this->public_services=$input;}
	function setPaymentMethodIds($input){ $this->payment_method_ids=$input;}
	function setPublicPaymentMethod($input){ $this->public_payment_method=$input;}
	function setTransportIncludeId($input){ $this->transport_include_id=$input;}
	function setPublicTransportInclude($input){ $this->public_transport_include=$input;}
	function setPublicPhone($input){ $this->public_phone=$input;}
	function setPublicEmail($input){ $this->public_email=$input;}
	function setPublicAddress($input){ $this->public_address=$input;}
	function setGeolocation($input){ $this->geolocation=$input;}
	function setPublicGeolocation($input){ $this->public_geolocation=$input;}
	function setPublicMap($input){ $this->public_map=$input;}
	function setShowAddressOnMap($input){ $this->show_address_on_map=$input;}
	function setReceiveMessage($input){ $this->receive_message=$input;}
	function setPromotionCode($input){ $this->promotion_code=$input;}
	function setCommericalLead($input){ $this->commercial_lead=$input;}
	function setPackageIds($input){ $this->package_ids=$input;}
	function setServesToIds($input){ $this->serves_to_ids=$input;}
	function setPublicServesTo($input){ $this->public_serves_to=$input;}
	function setPublicWorkingCalendar($input){ $this->public_working_calendar=$input;}
	function setPublicPricingTime($input){ $this->public_pricing_time=$input;}
	function setExtrasIds($input){ $this->extras_ids=$input;}
	function setPublicExtras($input){ $this->public_extras=$input;}
	function setExpireContractTime($input){ $this->expire_contract_time=$input; }
	function setSubscriptionId($input){ $this->subscription_id=$input; }
	function setEscortCategoryId($input){ $this->escort_category_id=$input; }
	function setLanguageIds($input){ $this->language_ids=$input; }
	function setPublicLanguageIds($input){ $this->public_language_ids=$input; }
	function setPoint($input){ $this->point=$input; }
	function setPublished($input){$this->published=$input;}
	function setPaymentPending($input){$this->payment_pending=$input;}
	function setBreastsSizeId($input){ $this->breasts_size_id=$input; }
	function setPublicBreastsSize($input){ $this->public_breasts_size=$input; }
	function setPenisSizeId($input){ $this->penis_size_id=$input; }
	function setPublicPenisSize($input){ $this->public_penis_size=$input; }
	function setEscortName($input){ $this->escort_name=$input; }
	function setEscortEmail($input){ $this->escort_email=$input; }
	function setEscortAddress($input){ $this->escort_address=$input; }
	function setEscortPhone($input){ $this->escort_phone=$input; }
	function setStateId($input){ $this->state_id=$input; }
	function setProvinceId($input){ $this->province_id=$input; }
	function setCityId($input){ $this->city_id=$input; }
	function setPlacesListIdsContract($input){ $this->places_list_ids_contract=$input; }
	function setPriorityId($input){ $this->priority_id = $input; }
	function setAddPointEditProfile($input){ $this->add_point_edit_profile = $input; }
	function setProfessionId($input){ $this->profession_id=$input;}
	function setPublicProfession($input){ $this->public_profession=$input;}
	function setImageFaceCensor($input){$this->image_face_censor=$input;}
	function setApplyServices($input){$this->apply_services=$input;}
	function setBornCountryId($input){$this->borncountry_id=$input;}
	function setPublicBorncountry($input){$this->public_borncountry=$input;}
	function setOrderControll($input){$this->order_controll=$input;}
	function setOrderValue($input){$this->order_value=$input;}
			
	function getId(){ return $this->id;}
	function getUserId(){ return $this->user_id;}
	function getTimesVisited(){ return $this->times_visited;}
	function getNumberFirstStanding(){ return $this->number_first_standing; }
	function getTimesPhoneDisplayed(){ return $this->times_phone_displayed;}
	function getWallet(){ return $this->wallet;}
	function getSex(){ return $this->sex;}
	function getPublicSex(){ return $this->public_sex;}
	function getSexualOrientationId(){ return $this->sexual_orientation_id;}
	function getPublicSexualOrientation(){ return $this->public_sexual_orientation;}
	function getBirthDate(){ return $this->birth_date;}
	function getPublicBirthDate(){ return $this->public_birth_date;}
	function getCountryId(){ return $this->country_id;}
	function getPublicCountry(){ return $this->public_country;}
	function getHairColorId(){ return $this->hair_color_id;}
	function getHairSizeId(){ return $this->hair_size_id;}
	function getHairStyleId(){ return $this->hair_style_id;}
	function getPublicHair(){ return $this->public_hair;}
	function getEyeId(){ return $this->eye_id;}
	function getPublicEye(){ return $this->public_eye;}
	function getHeight(){ return $this->height;}
	function getPublicHeight(){ return $this->public_height;}
	function getWeight(){ return $this->weight;}
	function getPublicWeight(){ return $this->public_weight;}
	function getMeasure1(){ return $this->measure_1;}
	function getMeasure2(){ return $this->measure_2;}
	function getMeasure3(){ return $this->measure_3;}
	function getPublicMeasures(){ return $this->public_measures;}
	function getPublicSchedule(){ return $this->public_schedule;}
	function getWorkingPlaceIds(){ return $this->working_place_ids;}
	function getPublicWorkingPlaces(){ return $this->public_working_places;}
	function getTravelIds(){ return $this->travel_ids;}
	function getPublicTravel(){ return $this->public_travel;}
	function getServeToIds(){ return $this->serve_to_ids;}
	function getPublicServeTo(){ return $this->public_serve_to;}
	function getServiceIds(){ return $this->service_ids;}
	function getPublicServices(){ return $this->public_services;}
	function getPaymentMethodIds(){ return $this->payment_method_ids;}
	function getPublicPaymentMethod(){ return $this->public_payment_method;}
	function getTransportIncludeId(){ return $this->transport_include_id;}
	function getPublicTransportInclude(){return $this->public_transport_include;}
	function getPublicPhone(){ return $this->public_phone;}
	function getPublicEmail(){ return $this->public_email;}
	function getPublicAddress(){ return $this->public_address;}
	function getGeolocation(){ return $this->geolocation;}
	function getPublicGeolocation(){ return $this->public_geolocation;}
	function getPublicMap(){ return $this->public_map;}
	function getShowAddressOnMap(){ return $this->show_address_on_map;}
	function getReceiveMessage(){ return $this->receive_message;}
	function getPromotionCode(){ return $this->promotion_code;}
	function getCommericalLead(){ return $this->commercial_lead;}
	function getPackageIds(){ return $this->package_ids;}
	function getServesToIds(){ return $this->serves_to_ids;}
	function getPublicServesTo(){ return $this->public_serves_to;}
	function getPublicWorkingCalendar(){ return $this->public_working_calendar;}
	function getPublicPricingTime(){ return $this->public_pricing_time;}
	function getExtrasIds(){ return $this->extras_ids;}
	function getPublicExtras(){return  $this->public_extras;}
	function getExpireContractTime(){ return $this->expire_contract_time; }
	function getSubscriptionId(){ return $this->subscription_id; }
    function getEscortCategoryId(){ return $this->escort_category_id; }
	function getLanguageIds(){ return $this->language_ids; }
	function getPublicLanguageIds(){ return $this->public_language_ids; }
	function getPoint(){ return $this->point; }
	function getPublished(){ return $this->published; }
	function getPaymentPending(){return $this->payment_pending;}
	function getBreastsSizeId(){ return $this->breasts_size_id; }
	function getPublicBreastsSize(){ return $this->public_breasts_size; }
	function getPenisSizeId(){ return $this->penis_size_id; }
	function getPublicPenisSize(){ return $this->public_penis_size; }
	function getEscortName(){ return $this->escort_name; }
	function getEscortEmail(){ return $this->escort_email; }
	function getEscortAddress(){ return $this->escort_address; }
	function getEscortPhone(){ return $this->escort_phone; }
	function getStateId(){ return $this->state_id; }
	function getProvinceId(){ return $this->province_id; }
	function getCityId(){ return $this->city_id; }
	function getPlacesListIdsContract(){ return $this->places_list_ids_contract; }
	function getPriorityIds(){ return $this->priority_id; }
	function getAddPointEditProfile(){ return $this->add_point_edit_profile; }
	function getProfessionId(){ return $this->profession_id;}
	function getPublicProfession(){ return $this->public_profession;}
	function getImageFaceCensor(){return $this->image_face_censor;}
	function getApplyServices(){return $this->apply_services;}
	function getBornCountryId(){return $this->borncountry_id;}
	function getPublicBorncountry(){return $this->public_borncountry;}
	function getOrderControll(){return $this->order_controll;}
	function getOrderValue(){return $this->order_value;}
	
	function update()
	{
		$this->CI->db->set_dbprefix('default_');
		
		$LOCKED = $this->CI->locked_escort_entity->init('escort_id', $this->id);
		
		$this->CI->db->set('times_visited', $this->times_visited);
		$this->CI->db->set('number_first_standing', $this->number_first_standing);
		$this->CI->db->set('times_phone_displayed', $this->times_phone_displayed);
		$this->CI->db->set('wallet', $this->wallet);
		if($LOCKED->getLockedSex() != 1){
			$this->CI->db->set('sex', $this->sex);
			$this->CI->db->set('public_sex', $this->public_sex);
			$this->CI->db->set('breasts_size_id', $this->breasts_size_id);
			$this->CI->db->set('public_breasts_size', $this->public_breasts_size);
			$this->CI->db->set('penis_size_id', $this->penis_size_id);
			$this->CI->db->set('public_penis_size', $this->public_penis_size);
		}
		if($LOCKED->getLockedSexualOrientation() != 1){
			$this->CI->db->set('sexual_orientation_id', $this->sexual_orientation_id);
			$this->CI->db->set('public_sexual_orientation', $this->public_sexual_orientation);
		}
		if($LOCKED->getLockedBirthDate() != 1){
			$this->CI->db->set('birth_date', $this->birth_date);
			$this->CI->db->set('public_birth_date', $this->public_birth_date);
		}
		if($LOCKED->getLockedCountry() != 1){
			$this->CI->db->set('country_id', $this->country_id);
			$this->CI->db->set('public_country', $this->public_country);
			$this->CI->db->set('state_id', $this->state_id);
			$this->CI->db->set('province_id', $this->province_id);
			$this->CI->db->set('city_id', $this->city_id);
		}
		if($LOCKED->getLockedHair() != 1){
			$this->CI->db->set('hair_color_id', $this->hair_color_id);
			$this->CI->db->set('hair_size_id', $this->hair_size_id);
			$this->CI->db->set('hair_style_id', $this->hair_style_id);
			$this->CI->db->set('public_hair', $this->public_hair);
		}
		if($LOCKED->getLockedEye() != 1){
			$this->CI->db->set('eye_id', $this->eye_id);
			$this->CI->db->set('public_eye', $this->public_eye);
		}
		if($LOCKED->getLockedHeight() != 1){
			$this->CI->db->set('height', $this->height);
			$this->CI->db->set('public_height', $this->public_height);
		}
		if($LOCKED->getLockedWeight() != 1){
			$this->CI->db->set('weight', $this->weight);
			$this->CI->db->set('public_weight', $this->public_weight);
		}
		if($LOCKED->getLockedMeasures() != 1){
			$this->CI->db->set('measure_1', $this->measure_1);
			$this->CI->db->set('measure_2', $this->measure_2);
			$this->CI->db->set('measure_3', $this->measure_3);
			$this->CI->db->set('public_measures', $this->public_measures);
		}
		if($LOCKED->getLockedSchedule() != 1){
			$this->CI->db->set('public_schedule', $this->public_schedule);
		}
		if($LOCKED->getLockedWorkingCalendar() != 1){
			$this->CI->db->set('public_working_calendar', $this->public_working_calendar);
		}
		if($LOCKED->getLockedWorkingPlaces() != 1){
			$this->CI->db->set('working_place_ids', $this->working_place_ids);
			$this->CI->db->set('public_working_places', $this->public_working_places);
		}
		if($LOCKED->getLockedTravel() != 1){
			$this->CI->db->set('travel_ids', $this->travel_ids);
			$this->CI->db->set('public_travel', $this->public_travel);
		}
		if($LOCKED->getLockedServe_to() != 1){
			$this->CI->db->set('serve_to_ids', $this->serve_to_ids);
			$this->CI->db->set('public_serve_to', $this->public_serve_to);
			$this->CI->db->set('serves_to_ids', $this->serves_to_ids);
			$this->CI->db->set('public_serves_to', $this->public_serves_to);
		}
		if($LOCKED->getLockedServices() != 1){
			$this->CI->db->set('service_ids', $this->service_ids);
			$this->CI->db->set('public_services', $this->public_services);
		}
		if($LOCKED->getLockedPaymentMethod() != 1){
			$this->CI->db->set('payment_method_ids', $this->payment_method_ids);
			$this->CI->db->set('public_payment_method', $this->public_payment_method);
		}
		if($LOCKED->getLockedPricingTime() != 1){
			$this->CI->db->set('public_pricing_time', $this->public_pricing_time);
		}
		if($LOCKED->getLockedExtras() != 1){
			$this->CI->db->set('extras_ids', $this->extras_ids);
			$this->CI->db->set('public_extras', $this->public_extras);
		}
		if($LOCKED->getLockedTransport() != 1){
			$this->CI->db->set('transport_include_id', $this->transport_include_id);
			$this->CI->db->set('public_transport_include', $this->public_transport_include);
		}
		if($LOCKED->getLockedPhone() != 1){
			$this->CI->db->set('public_phone', $this->public_phone);
		}
		if($LOCKED->getLockedEmail() != 1){
			$this->CI->db->set('public_email', $this->public_email);
		}
		if($LOCKED->getLockedAddress() != 1){
			$this->CI->db->set('public_address', $this->public_address);
		}
		if($LOCKED->getLockedGeolocation() != 1){
			$this->CI->db->set('geolocation', $this->geolocation);
			$this->CI->db->set('public_geolocation', $this->public_geolocation);
		}
		if($LOCKED->getLockedMap() != 1){
			$this->CI->db->set('public_map', $this->public_map);
			$this->CI->db->set('show_address_on_map', $this->show_address_on_map);
		}
		if($LOCKED->getLockedLanguageIds() != 1){
			$this->CI->db->set('public_language_ids', $this->public_language_ids);
			$this->CI->db->set('language_ids', $this->language_ids);
		}
		if($LOCKED->getLockedProfession() != 1){
			$this->CI->db->set('profession_id', $this->profession_id);
			$this->CI->db->set('public_profession', $this->public_profession);
		}
		if($LOCKED->getLockedBornCountry() != 1){
			$this->CI->db->set('borncountry_id', $this->borncountry_id);
			$this->CI->db->set('public_borncountry', $this->public_borncountry);
		}
		
		$this->CI->db->set('receive_message', $this->receive_message);
		$this->CI->db->set('promotion_code', $this->promotion_code);
		$this->CI->db->set('commercial_lead', $this->commercial_lead);
		$this->CI->db->set('package_ids', $this->package_ids);
		$this->CI->db->set('expire_contract_time', $this->expire_contract_time);
		$this->CI->db->set('subscription_id', $this->subscription_id);
		$this->CI->db->set('escort_category_id', $this->escort_category_id);
		
		if($this->point < 0){
			$this->point = 0;
		}
		$this->CI->db->set('point', $this->point);
		$this->CI->db->set('published', $this->published);
		$this->CI->db->set('payment_pending', $this->payment_pending);
		$this->CI->db->set('escort_name', $this->escort_name);
		$this->CI->db->set('escort_email', $this->escort_email);
		$this->CI->db->set('escort_address', $this->escort_address);
		$this->CI->db->set('escort_phone', $this->escort_phone);
		$this->CI->db->set('image_face_censor', $this->image_face_censor);
		
		$this->CI->db->set('places_list_ids_contract', $this->places_list_ids_contract);
		$this->CI->db->set('priority_id', $this->priority_id);
		$this->CI->db->set('apply_services',$this->apply_services);
		
		$this->CI->db->set('order_controll', $this->order_controll);
		$this->CI->db->set('order_value', $this->point + $this->order_controll );
		
		$this->CI->db->set('user_id', $this->user_id);
		$this->CI->db->where('id', $this->id)->update(TBL_ESCORT);
		
	}
	function adminUpdate()
	{		
		$this->CI->db->set_dbprefix('default_');
		
		$this->CI->db->set('times_visited', $this->times_visited);
		$this->CI->db->set('number_first_standing', $this->number_first_standing);
		$this->CI->db->set('times_phone_displayed', $this->times_phone_displayed);
		$this->CI->db->set('wallet', $this->wallet);
		$this->CI->db->set('sex', $this->sex);
		$this->CI->db->set('public_sex', $this->public_sex);
		$this->CI->db->set('breasts_size_id', $this->breasts_size_id);
		$this->CI->db->set('public_breasts_size', $this->public_breasts_size);
		$this->CI->db->set('penis_size_id', $this->penis_size_id);
		$this->CI->db->set('public_penis_size', $this->public_penis_size);
	
		$this->CI->db->set('sexual_orientation_id', $this->sexual_orientation_id);
		$this->CI->db->set('public_sexual_orientation', $this->public_sexual_orientation);
		
		$this->CI->db->set('birth_date', $this->birth_date);
		$this->CI->db->set('public_birth_date', $this->public_birth_date);
	
		$this->CI->db->set('country_id', $this->country_id);
		$this->CI->db->set('public_country', $this->public_country);
		$this->CI->db->set('state_id', $this->state_id);
		$this->CI->db->set('province_id', $this->province_id);
		$this->CI->db->set('city_id', $this->city_id);
	
		$this->CI->db->set('hair_color_id', $this->hair_color_id);
		$this->CI->db->set('hair_size_id', $this->hair_size_id);
		$this->CI->db->set('hair_style_id', $this->hair_style_id);
		$this->CI->db->set('public_hair', $this->public_hair);
	
		$this->CI->db->set('eye_id', $this->eye_id);
		$this->CI->db->set('public_eye', $this->public_eye);
	
		$this->CI->db->set('height', $this->height);
		$this->CI->db->set('public_height', $this->public_height);
	
		$this->CI->db->set('weight', $this->weight);
		$this->CI->db->set('public_weight', $this->public_weight);
	
		$this->CI->db->set('measure_1', $this->measure_1);
		$this->CI->db->set('measure_2', $this->measure_2);
		$this->CI->db->set('measure_3', $this->measure_3);
		$this->CI->db->set('public_measures', $this->public_measures);
	
		$this->CI->db->set('public_schedule', $this->public_schedule);
	
		$this->CI->db->set('public_working_calendar', $this->public_working_calendar);
	
		$this->CI->db->set('working_place_ids', $this->working_place_ids);
		$this->CI->db->set('public_working_places', $this->public_working_places);
	
		$this->CI->db->set('travel_ids', $this->travel_ids);
		$this->CI->db->set('public_travel', $this->public_travel);
	
		$this->CI->db->set('serve_to_ids', $this->serve_to_ids);
		$this->CI->db->set('public_serve_to', $this->public_serve_to);
		$this->CI->db->set('serves_to_ids', $this->serves_to_ids);
		$this->CI->db->set('public_serves_to', $this->public_serves_to);
	
		$this->CI->db->set('service_ids', $this->service_ids);
		$this->CI->db->set('public_services', $this->public_services);
	
		$this->CI->db->set('payment_method_ids', $this->payment_method_ids);
		$this->CI->db->set('public_payment_method', $this->public_payment_method);
	
		$this->CI->db->set('public_pricing_time', $this->public_pricing_time);
	
		$this->CI->db->set('extras_ids', $this->extras_ids);
		$this->CI->db->set('public_extras', $this->public_extras);
	
		$this->CI->db->set('transport_include_id', $this->transport_include_id);
		$this->CI->db->set('public_transport_include', $this->public_transport_include);
	
		$this->CI->db->set('public_phone', $this->public_phone);
	
		$this->CI->db->set('public_email', $this->public_email);
	
		$this->CI->db->set('public_address', $this->public_address);
	
		$this->CI->db->set('geolocation', $this->geolocation);
		$this->CI->db->set('public_geolocation', $this->public_geolocation);
	
		$this->CI->db->set('public_map', $this->public_map);
		$this->CI->db->set('show_address_on_map', $this->show_address_on_map);
	
		$this->CI->db->set('public_language_ids', $this->public_language_ids);
		$this->CI->db->set('language_ids', $this->language_ids);
	
		$this->CI->db->set('receive_message', $this->receive_message);
		$this->CI->db->set('promotion_code', $this->promotion_code);
		$this->CI->db->set('commercial_lead', $this->commercial_lead);
		$this->CI->db->set('package_ids', $this->package_ids);
		$this->CI->db->set('expire_contract_time', $this->expire_contract_time);
		$this->CI->db->set('subscription_id', $this->subscription_id);
		$this->CI->db->set('escort_category_id', $this->escort_category_id);
	
		$this->CI->db->set('point', $this->point);
		$this->CI->db->set('published', $this->published);
		$this->CI->db->set('payment_pending', $this->payment_pending);
		$this->CI->db->set('escort_name', $this->escort_name);
		$this->CI->db->set('escort_email', $this->escort_email);
		$this->CI->db->set('escort_address', $this->escort_address);
		$this->CI->db->set('escort_phone', $this->escort_phone);
		
		$this->CI->db->set('places_list_ids_contract', $this->places_list_ids_contract);
		$this->CI->db->set('priority_id', $this->priority_id);
		$this->CI->db->set('profession_id', $this->profession_id);
		$this->CI->db->set('public_profession', $this->public_profession);
		$this->CI->db->set('user_id', $this->user_id);
		
		$this->CI->db->set('borncountry_id', $this->borncountry_id);
		$this->CI->db->set('public_borncountry', $this->public_borncountry);
		
		$this->CI->db->set('order_controll', $this->order_controll);
		$this->CI->db->set('order_value', $this->point + $this->order_controll );
		
		$this->CI->db->where('id', $this->id)->update(TBL_ESCORT);
		
	}
	
	function createNewEscortEntity(){
		$this->CI->db->set_dbprefix('default_');
		
		$this->CI->db->set('times_visited', 0 );
		$this->CI->db->insert(TBL_ESCORT);
		return $this->CI->db->insert_id();
	}
	
	function setDescription($description, $language_id, $escort_id, $time){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'language_id'=>$language_id) )->get(TBL_ESCORT_DESCRIPTION)->result();
		if(empty($result)) {
			$this->CI->escort_description_entity->setEscortId($escort_id);
			$this->CI->escort_description_entity->setLanguageId($language_id);
			$this->CI->escort_description_entity->setDescription($description);
			$this->CI->escort_description_entity->setTimeStamp($time);
			$this->CI->escort_description_entity->save();
		}else{
			$OBJ = $this->CI->escort_description_entity->init('id',$result[0]->id);
			$OBJ->setEscortId($escort_id);
			$OBJ->setLanguageId($language_id);
			$OBJ->setDescription($description);
			$OBJ->setTimeStamp($time);
			$OBJ->update();
		}
	}
	
	function setTranslateMode($mode, $isSource, $language_id, $escort_id){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'language_id'=>$language_id) )->get(TBL_ESCORT_DESCRIPTION)->result();
		if(empty($result)) {
			$this->CI->escort_description_entity->setEscortId($escort_id);
			$this->CI->escort_description_entity->setLanguageId($language_id);
			$this->CI->escort_description_entity->setTransMode($mode);
			$this->CI->escort_description_entity->setIsSource($isSource);
			$this->CI->escort_description_entity->save();
		}else{
			$OBJ = $this->CI->escort_description_entity->init('id',$result[0]->id);
			$OBJ->setEscortId($escort_id);
			$OBJ->setLanguageId($language_id);
			$OBJ->setTransMode($mode);
			$OBJ->setIsSource($isSource);
			$OBJ->update();
		}
	}
	
	function getDescription($language_id,$escort_id){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'language_id'=>$language_id) )->get(TBL_ESCORT_DESCRIPTION)->result();
		if(!empty($result)) {
			return $result[0]->description;
		}
		return '';
	}
	
	function getTranslateMode($language_id,$escort_id){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'language_id'=>$language_id) )->get(TBL_ESCORT_DESCRIPTION)->result();
		if(!empty($result)) {
			return $result[0]->trans_mode;
		}
		return 1;
	}
	
	function setSchedule($escort_id, $weekday_id, $from, $to){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'week_day'=>$weekday_id) )->get(TBL_SCHEDULE)->result();
		if(empty($result)) {
			$this->CI->db->set('escort_id',$escort_id);
			$this->CI->db->set('week_day',$weekday_id);
			$this->CI->db->set('from',$from);
			$this->CI->db->set('to',$to);
			$this->CI->db->insert(TBL_SCHEDULE);
		}else{
			$OBJ = $this->CI->schedule_entity->init('id',$result[0]->id);
			$OBJ->setEscortId($escort_id);
			$OBJ->setWeekDay($weekday_id);
			$OBJ->setFrom($from);
			$OBJ->setTo($to);
			$OBJ->update();
		}
	}
	
	function getSchedule($escort_id, $weekday_id){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'week_day'=>$weekday_id) )->get(TBL_SCHEDULE)->result();
		if(!empty($result)) {
			return $result[0];
		}
		return false;
	}
	
	function getWeekdaysArray($escort_id){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where('escort_id', $escort_id)->get(TBL_SCHEDULE)->result();
		$array_return = array();
		foreach($result as $item){
			$array_return[] = $item->week_day;	
		}
		return $array_return;
	}
	
	function setWorkingCalendar($escort_id, $year, $month, $dateString){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'year'=>$year, 'month'=> $month) )->get(TBL_WORKING_DATE)->result();
		if(empty($result)) {
			$this->CI->working_date_entity->setEscortId($escort_id);
			$this->CI->working_date_entity->setYear($year);
			$this->CI->working_date_entity->setMonth($month);
			$this->CI->working_date_entity->setDates($dateString);
			$this->CI->working_date_entity->save();
		}else{
			$OBJ = $this->CI->working_date_entity->init('id',$result[0]->id);
			$OBJ->setDates($dateString);
			$OBJ->update();
		}
	}
	
	function getWorkingCalendar($escort_id, $year, $month){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'year'=>$year, 'month'=> $month) )->get(TBL_WORKING_DATE)->result();
		if(!empty($result)) {
			return $result[0];
		}
		return false;
	}
	
	function setPricingTime($escort_id, $time_id, $price){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'pricing_time_id'=>$time_id ) )->get(TBL_PRICING_TIME)->result();
		if(empty($result)) {
			$this->CI->pricing_time_entity->setEscortId($escort_id);
			$this->CI->pricing_time_entity->setPricingTimeId($time_id);
			$this->CI->pricing_time_entity->setPrice($price);
			$this->CI->pricing_time_entity->save();
		}else{
			$OBJ = $this->CI->pricing_time_entity->init('id',$result[0]->id);
			$OBJ->setPrice($price);
			$OBJ->update();
		}
	}
	
	function getPricingTime($escort_id, $time_id){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where( array('escort_id'=>$escort_id, 'pricing_time_id'=>$time_id ) )->get(TBL_PRICING_TIME)->result();
		if(!empty($result)) {
			return $result[0];
		}
		return false;
	}
	
	function getPricingTimeIdArray($escort_id){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->where('escort_id', $escort_id)->get(TBL_PRICING_TIME)->result();
		$array_return = array();
		foreach($result as $item){
			$array_return[] = $item->pricing_time_id;	
		}
		return $array_return;
	}
	
	function getMinPrice(){
		$this->CI->db->set_dbprefix('default_');
		
		$rs = $this->CI->db->query("SELECT MIN(price) AS price FROM ".TBL_PRICING_TIME." WHERE escort_id=".$this->getId())->result();
		return ($rs[0]->price) ? $rs[0]->price.' &euro;' : '';
	}
	
	function increaseNumberOfFirstStanding(){
		$this->setNumberFirstStanding( 1 + $this->getNumberFirstStanding() );
		$this->update();
	}
	
	function subtractPointEscostListingPage(){
		$this->setPoint( $this->getPoint() - POINT_SUBTRACT_LISTING_PAGE );
		$this->update();
		
		$POINT_LOG = $this->CI->point_log_entity->createNewEntity();
		$POINT_LOG->setAction('SUBTRACT');
		$POINT_LOG->setEscortId($this->getId());
		$POINT_LOG->setAmount(POINT_SUBTRACT_LISTING_PAGE);
		$POINT_LOG->setCurrentPoint($this->getPoint());
		$POINT_LOG->setSiteRef(SITE_REF);
		$POINT_LOG->setDescription('SUBTRACT POINT WHEN ESCORT ON LISTING');
		$POINT_LOG->update();
	}
	
	function subtractPointEscortProfilePage(){
		$this->setPoint( $this->getPoint() - POINT_SUBTRACT_PROFILE_PAGE );
		$this->update();
		
		$POINT_LOG = $this->CI->point_log_entity->createNewEntity();
		$POINT_LOG->setAction('SUBTRACT');
		$POINT_LOG->setEscortId($this->getId());
		$POINT_LOG->setAmount(POINT_SUBTRACT_PROFILE_PAGE);
		$POINT_LOG->setCurrentPoint($this->getPoint());
		$POINT_LOG->setSiteRef(SITE_REF);
		$POINT_LOG->setDescription('SUBTRACT POINT WHEN VISITOR CLICK TO ESCORT PROFILE PAGE');
		$POINT_LOG->update();
	}
	
	function addPointEscortProfilePage(){
		$this->setPoint( $this->getPoint() + POINT_ADD_CONNECT_PROFILE );
		$this->update();
		
		$POINT_LOG = $this->CI->point_log_entity->createNewEntity();
		$POINT_LOG->setAction('ADD');
		$POINT_LOG->setEscortId($this->getId());
		$POINT_LOG->setAmount(POINT_ADD_CONNECT_PROFILE);
		$POINT_LOG->setCurrentPoint($this->getPoint());
		$POINT_LOG->setSiteRef(SITE_REF);
		$POINT_LOG->setDescription('ADD POINT WHEN VISITOR CLICK TO ESCORT PROFILE PAGE');
		$POINT_LOG->update();
	}
	
	function addPointEscortEditProfile(){
		if($this->getAddPointEditProfile() != 1){
			$total = 	$this->getPublicSex()
						+ $this->getPublicSexualOrientation()
						+ $this->getPublicBirthDate()
						+ $this->getPublicCountry()
						+ $this->getPublicHair()
						+ $this->getPublicEye()
						+ $this->getPublicHeight()
						+ $this->getPublicWeight()
						+ $this->getPublicMeasures()
						+ $this->getPublicSchedule()
						+ $this->getPublicWorkingPlaces()
						+ $this->getPublicTravel()
						+ $this->getPublicServeTo()
						+ $this->getPublicServices()
						+ $this->getPublicTransportInclude()
						+ $this->getPublicPhone()
						+ $this->getPublicEmail()
						+ $this->getPublicAddress()
						+ $this->getPublicGeolocation()
						+ $this->getPublicMap()
						+ $this->getPublicServesTo()
						+ $this->getPublicWorkingCalendar()
						+ $this->getPublicPricingTime()
						+ $this->getPublicExtras()
						+ $this->getPublicLanguageIds()
						+ $this->getPublicProfession()
						+ $this->getPublicPaymentMethod()
						+ $this->getPublicBorncountry()
					//	+ $this->getPublicBreastsSize()
					//	+ $this->getPublicPenisSize()		
						;
			$percent = 	(float) $total/28 ;		
			if( $percent > 0.8){
				$this->setPoint( $this->getPoint() + POINT_ADD_EDIT_PROFILE );
				$this->setAddPointEditProfile(1);
				$this->update();
				
				$POINT_LOG = $this->CI->point_log_entity->createNewEntity();
				$POINT_LOG->setAction('ADD');
				$POINT_LOG->setEscortId($this->getId());
				$POINT_LOG->setAmount(POINT_ADD_EDIT_PROFILE);
				$POINT_LOG->setCurrentPoint($this->getPoint());
				$POINT_LOG->setSiteRef(SITE_REF);
				$POINT_LOG->setDescription('ADD POINT WHEN ESCORT PUBLIC PROFILE INFOMATION');
				$POINT_LOG->update();
			}
		}
	}
	
	function getEscortList($limit){
		$this->CI->db->set_dbprefix('default_');
		
		$result = $this->CI->db->limit($limit[0], $limit[1])->order_by('user_id','desc')->get(TBL_ESCORT)->result();
		return $result;
	}
	function getEscortListByUser($userIdList, $limit){
		$this->CI->db->set_dbprefix('default_');
		
		$this->CI->db->where_in('user_id', $userIdList);
		$result = $this->CI->db->limit($limit[0], $limit[1])->order_by('user_id','desc')->get(TBL_ESCORT)->result();
		return $result;
	}
	function countAllEscort(){
		$this->CI->db->set_dbprefix('default_');
		
		return $this->CI->db->order_by('user_id','desc')->count_all_results(TBL_ESCORT);
	}
	function countEscortByUser($userIdList){
		$this->CI->db->set_dbprefix('default_');
		
		$this->CI->db->where_in('user_id', $userIdList);
		return $this->CI->db->count_all_results(TBL_ESCORT);
	}
	function countEscortByEscortIdList($escortIdList){
		$this->CI->db->set_dbprefix('default_');
		
		return $this->CI->db->where_in('id', $escortIdList)->order_by('user_id','desc')->count_all_results(TBL_ESCORT);
	}
	function getEscortByEscortIdList($escortIdList, $limit = array()){
		$this->CI->db->set_dbprefix('default_');
		
		$this->CI->db->where_in('id', $escortIdList);
		if($limit && count($limit) > 0){
			$this->CI->db->limit($limit[0], $limit[1])->order_by('user_id','desc');
		}
		$result = $this->CI->db->order_by('user_id','desc')->get(TBL_ESCORT)->result();
		return $result;
	}
	public function countPendingReviewEscort($escortIdList){
		$this->CI->db->set_dbprefix('default_');
		
		$this->CI->db->where_in('id', $escortIdList);
		$this->CI->db->where_not_in('published', 1);
		$result = $this->CI->db->count_all_results(TBL_ESCORT);
		return $result;
	}
	public function countAbuseNotificationEscort($escortIdList){
		$this->CI->db->set_dbprefix('default_');
		
		$this->CI->db->where_in('id', $escortIdList);
		$this->CI->db->where('abuse_notification', 1);
		$result = $this->CI->db->count_all_results(TBL_ESCORT);
		return $result;
	}
	
	function checkEscortPermission(){
		$this->CI->db->set_dbprefix('default_');
		
		$rs = $this->CI->db->where('id',$this->getUserId())->get(TBL_USER)->result();
		return $rs ? $rs[0]->permission_slug : '';
	}
	
//end class
}	